﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations;

namespace TraceThisItem.Domain.Initializers
{
	public class TeamConfiguration : EntityTypeConfiguration<Team>
	{
		public TeamConfiguration()
		{
			HasKey(t => t.Id)
				.Property(t => t.Id)
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

			Property(t => t.Name)
				.HasMaxLength(200)
				.IsRequired()
				.IsUnicode(false);

			HasMany(t => t.Users)
				.WithMany(u => u.Teams);

			HasRequired(t => t.Project)
				.WithMany(p => p.Teams);

			Ignore(t => t.ProjectName);
		}
	}
}
